package test.my.com.myapplicationtest.grid_view_group;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import test.my.com.myapplicationtest.R;

/**
 * Author : cooper
 * Time :  2018/5/14 下午3:06
 * Description :
 */
public class GridViewGroupActivity extends Activity{

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.aty_grid_viewgroup);

        GridViewGroup gridViewGroup = (GridViewGroup) findViewById(R.id.gvp);

        for (int i = 0; i < 17; i++) {
            RelativeLayout relativeLayout = new RelativeLayout(this);
            relativeLayout.setBackgroundColor(Color.GRAY);

            TextView textView = new TextView(this);
            textView.setText("sdfsdf");
            textView.setTextColor(Color.GREEN);
            textView.setBackgroundColor(Color.BLUE);
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);

            relativeLayout.addView(textView,layoutParams);

            gridViewGroup.addView(relativeLayout);
        }
        gridViewGroup.requestLayout();
    }
}
